package com.holyant.goods.dto;

import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.domain.BaseDto;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 仓库SKU编码dto
 *
 * @author tswsoft
 * @date 2021-04-10
 */
@Data
@ApiModel("仓库SKU编码")
public class GdsSkuWarecodeDto extends BaseDto {

    private static final long serialVersionUID = 1L;

    /**
     * 仓库id
     */
    @ApiModelProperty(value = "${comment}")
    private Long warehouseId;

    /**
     * 仓库名称
     */
    @Excel(name = "仓库名称")
    @ApiModelProperty(value = "仓库名称")
    private String warehouseName;

    /**
     * 仓库sku编码
     */
    @Excel(name = "仓库SKU编码")
    @ApiModelProperty(value = "仓库SKU编码")
    private String wareSkuCode;

    /**
     * 仓库申报价格
     */
    @Excel(name = "仓库申报价格")
    @ApiModelProperty(value = "仓库申报价格")
    private BigDecimal wareSkuPrc;

    /**
     * sku id
     */
    @ApiModelProperty(value = "sku id")
    private Long skuId;

    /**
     * sku编码
     */
    @Excel(name = "SKU编码")
    @ApiModelProperty(value = "SKU编码")
    private String skuCode;

    /**
     * sku名称
     */
    @Excel(name = "SKU名称")
    @ApiModelProperty(value = "SKU名称")
    private String skuName;

    /**
     * 商品编码
     */
    @Excel(name = "商品编码")
    @ApiModelProperty(value = "商品编码")
    private String goodsCode;

    /**
     * 商品名称
     */
    @Excel(name = "商品名称")
    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    /**
     * 商品条码
     */
    @Excel(name = "商品条码")
    @ApiModelProperty(value = "商品条码")
    private String goodsBarcode;

    /**
     * 所属分类
     */
    @Excel(name = "所属分类")
    @ApiModelProperty(value = "所属分类")
    private String categoryName;

    /**
     * 失效日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "失效日期")
    private LocalDate expireDate;

    /**
     * 规格编码json
     */
    @Excel(name = "规格编码")
    @ApiModelProperty(value = "规格编码")
    private String wareSellSpec;


    public JSONArray getWareSellSpecArray(){
        if(StringUtils.isNotEmpty(this.wareSellSpec)){
            return JSONArray.parseArray(this.wareSellSpec);
        }
        return new JSONArray();
    }
}
